package com.ruoyi.web.controller.erpbase;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.SendoutCompany;
import com.ruoyi.system.service.ISendoutCompanyService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 供应商信息Controller
 * 
 * @author he
 * @date 2025-08-13
 */
@Api(tags = "供应商接口")
@RestController
@RequestMapping("/system/sendoutCompany")
public class SendoutCompanyController extends BaseController
{
    @Autowired
    private ISendoutCompanyService sendoutCompanyService;

    /**
     * 查询供应商信息列表
     */
    @ApiOperation("查询供应商信息")
    @PreAuthorize("@ss.hasPermi('system:sendoutCompany:list')")
    @GetMapping("/list")
    public TableDataInfo list(SendoutCompany sendoutCompany)
    {
        startPage();
        List<SendoutCompany> list = sendoutCompanyService.selectSendoutCompanyList(sendoutCompany);
        return getDataTable(list);
    }

    @ApiOperation("查询供应商下拉框信息")
    @PostMapping("/getSendOutCompanyInfoList")
    public TableDataInfo getSendOutCompanyInfoList(@RequestParam(value = "paramName", required = false) String paramName)
    {
        List<SendoutCompany> list = sendoutCompanyService.getSendOutCompanyInfoList(paramName);
        return getDataTable(list);
    }

    /**
     * 导出供应商信息列表
     */
    @ApiOperation("导出供应商信息")
    @PreAuthorize("@ss.hasPermi('system:sendoutCompany:export')")
    @Log(title = "供应商信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SendoutCompany sendoutCompany)
    {
        List<SendoutCompany> list = sendoutCompanyService.selectSendoutCompanyList(sendoutCompany);
        ExcelUtil<SendoutCompany> util = new ExcelUtil<SendoutCompany>(SendoutCompany.class);
        util.exportExcel(response, list, "供应商信息数据");
    }

    /**
     * 获取供应商信息详细信息
     */
    @ApiOperation("查询供应商详细信息")
    @PreAuthorize("@ss.hasPermi('system:sendoutCompany:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(sendoutCompanyService.selectSendoutCompanyById(id));
    }

    /**
     * 新增供应商信息
     */
    @ApiOperation("新增供应商信息")
    @PreAuthorize("@ss.hasPermi('system:sendoutCompany:add')")
    @Log(title = "供应商信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SendoutCompany sendoutCompany)
    {
        return toAjax(sendoutCompanyService.insertSendoutCompany(sendoutCompany));
    }

    /**
     * 修改供应商信息
     */
    @ApiOperation("修改供应商信息")
    @PreAuthorize("@ss.hasPermi('system:sendoutCompany:edit')")
    @Log(title = "供应商信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SendoutCompany sendoutCompany)
    {
        return toAjax(sendoutCompanyService.updateSendoutCompany(sendoutCompany));
    }

    /**
     * 删除供应商信息
     */
    @ApiOperation("删除供应商信息")
    @PreAuthorize("@ss.hasPermi('system:sendoutCompany:remove')")
    @Log(title = "供应商信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(sendoutCompanyService.deleteSendoutCompanyByIds(ids));
    }
}
